#include "net.hpp"

void onMessage(const myrpc::BaseConnection::ptr& conn, myrpc::BaseMessage::ptr& msg)
{
    std::string body = msg->serialize();
    std::cout << body << std::endl;
    auto rpc_rsp = myrpc::MessageFactory::create<myrpc::RpcResponse>();
    rpc_rsp->setId("11111");
    rpc_rsp->setMType(myrpc::MType::RSP_RPC);
    rpc_rsp->setRcode(myrpc::RCode::RCODE_OK);
    rpc_rsp->setResult(1);
    conn->send(rpc_rsp);
}

int main()
{
    auto server = myrpc::ServerFactory::create(9090);
    server->setMessageCallback(onMessage);
    server->start();
    return 0;
}